This is a run through my second assignment
Include your code in R chunks below, along with a walkthrough explanation in text of what you’re doing when answering the assignment sections below (the text can be either out here in the text portion of the RMarkdown document, or as commented lines within the chunks).
You can break things up into as many separate code chunks as you feel makes sense given the task at hand. Please feel free to make use of the material and code samples we went over in last week’s class to adapt to relevant scenarios below.
Create a small Excel spreadsheet file that contains the name along with latitude and longitude coordinates of four DC-area landmarks of your choosing.
Import the file into an R dataframe.
Using Leaflet, map out the four points on a Leaflet map, and set the zoom to the appropriate level.
landmark_data <- read_csv("landmark.csv")
leaflet(data=landmark_data) %>%
addTiles() %>%
addMarkers(~Longitude,~Latitude,label = ~Name)
The NYT’s publicly accessible covid case/death data by state is imported for you below into the dataframe covid. It contains a cumulative daily count of the total cases and deaths in a state as of each date.
The polygon boundaries of U.S. states and territories are included below as states.
Using the provided data, first filter the covid records to only include Feb. 22, 2021 - the day the U.S. crossed the half-a-million-deaths mark.
Once you have isolated just Feb. 22’s total deaths for every state, create a choropleth map (i.e. a shaded polygon map) that shows which states had more deaths as of Feb. 22 compared with others. Use either the Leaflet or Tmap package to do this.
#import the NYT's covid case data for states
covidcases <- read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-states.csv")
#Download the polygon boundaries for states at the lowest resolution using tigris package
states <- tigris::states(cb=T)
|
| | 0%
|
| | 1%
|
|= | 1%
|
|= | 2%
|
|== | 3%
|
|== | 4%
|
|=== | 4%
|
|=== | 5%
|
|==== | 6%
|
|==== | 7%
|
|===== | 9%
|
|====== | 9%
|
|====== | 10%
|
|====== | 11%
|
|======= | 11%
|
|======= | 12%
|
|======== | 14%
|
|========= | 15%
|
|========= | 16%
|
|========== | 17%
|
|=========== | 18%
|
|=========== | 19%
|
|============ | 20%
|
|============= | 22%
|
|============== | 23%
|
|=============== | 25%
|
|=============== | 26%
|
|================ | 26%
|
|================ | 27%
|
|================= | 28%
|
|================== | 30%
|
|=================== | 31%
|
|=================== | 32%
|
|==================== | 33%
|
|===================== | 35%
|
|====================== | 36%
|
|======================= | 38%
|
|======================== | 39%
|
|========================= | 42%
|
|========================== | 43%
|
|=========================== | 44%
|
|============================ | 46%
|
|============================ | 47%
|
|============================= | 48%
|
|============================= | 49%
|
|============================== | 50%
|
|=============================== | 51%
|
|================================ | 54%
|
|================================== | 56%
|
|================================== | 57%
|
|=================================== | 59%
|
|==================================== | 60%
|
|===================================== | 62%
|
|====================================== | 63%
|
|======================================= | 65%
|
|======================================= | 66%
|
|========================================= | 68%
|
|========================================== | 69%
|
|========================================== | 70%
|
|=========================================== | 72%
|
|============================================= | 74%
|
|============================================= | 75%
|
|============================================== | 76%
|
|============================================== | 77%
|
|=============================================== | 78%
|
|================================================ | 80%
|
|================================================= | 81%
|
|================================================= | 82%
|
|================================================== | 83%
|
|=================================================== | 84%
|
|=================================================== | 85%
|
|==================================================== | 86%
|
|===================================================== | 88%
|
|===================================================== | 89%
|
|====================================================== | 89%
|
|======================================================= | 91%
|
|======================================================== | 93%
|
|============================================================| 100%
A sample of Sacramento, Calif. real estate transactions are imported below for you into a dataframe called sac_sales.
First, take out any condo or multi-family dwellings so the type includes only residential sales.
Then, using either Leaflet or Tmap, create a map that shows the locations of the sales as dots on the map, with the size of the points based on the price the home sold for.
#your code here
sac_sales <- read_csv("https://support.spatialkey.com/wp-content/uploads/2021/02/Sacramentorealestatetransactions.csv")
residential_sales <- sac_sales %>%
filter(type=="Residential")
leaflet(residential_sales) %>%
addTiles() %>%
addCircleMarkers(
lng = ~longitude,
lat = ~latitude,
radius = ~price,
)
```{.r .distill-force-highlighting-css}